package com.qf.dao;

import com.qf.pojo.Type;
import com.qf.utils.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author hanjiejie
 * @version V1.0
 * @Project java2203
 * @Package com.qf.dao
 * @Description:
 * @Date 2022/5/25 15:56
 */
public class TypeDaoImpl implements  TypeDao{

    /**
     * 查询所有商品的分类
     */
 //创建Dbutil工具
   private QueryRunner queryRunner =  new QueryRunner(DBUtil.getDateSource());
    @Override
    public List<Type> findAll() {
    String sql ="select *from tb_goods_type";
        try {
            List<Type> list = queryRunner.query(sql, new BeanListHandler<Type>(Type.class));
            return list;
        } catch (SQLException e) {

        }
        return null;
    }
}
